<template>
  <div id="bottom">
    <van-tabbar v-model="active" active-color="#ee0a24" inactive-color="#333">
      <van-tabbar-item
        v-for="item in menuList"
        :to="item.router"
        :icon="item.icon"
        :key="item.id"
      >
        {{ item.title }}
      </van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  data() {
    return {
      path: "",
      active: 0,
      menuList: [
        {
          id: 1,
          title: "商城",
          icon: "home-o",
          router: "/home",
        },
        {
          id: 2,
          title: "分类",
          icon: "apps-o",
          router: "/class",
        },
        {
          id: 3,
          title: "购物车",
          icon: "cart-o",
          router: "/cart",
        },
        {
          id: 4,
          title: "我",
          icon: "contact",
          router: "/user",
        },
      ],
    };
  },
  methods: {
    change(i) {
      this.active = i;
    },
  },
  mounted() {
    this.menuList.forEach((item, index) => {
      if (item.router == this.$route.path) {
        this.active = index;
      }
    });
  },
};
</script>

<style scoped>
#bottom {
  z-index: 999;
  height: 0.49rem;
  width: 3.75rem;
  background: white;
  position: fixed;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.25rem;
  background: #ffffff;
  box-shadow: 0 -0.05rem 0.1rem 0 rgba(204, 204, 204, 0.2), 0 0 0 0 #cccccc;
}
.item {
  width: 0.5rem;
  height: 0.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  align-items: center;
}
.item p {
  font-size: 0.1rem;
  transform: scale(0.83);
}
.item p.active {
  color: #ff6040;
}
.item img {
  width: 0.2rem;
}
</style>